﻿function checkdata() {
	
	
	if(!checkUsername()||!checkPassword()||!checkRePassword()||!checkRealName()||!checkMail()
			||!checkCode()){
		return false;
	}
	return true;
}




function checkUsername(){
	var ssn = reg.username.value;
	if(ssn.length<1 ||ssn.length>17){
//		alert("用户名长度在1-17位");
		document.getElementById("usernameE").innerHTML="<font color=red>用户名长度在1-17位</font>"
		
		return false;
		
	}
	document.getElementById("usernameE").innerHTML=""
	if(checkSpace(ssn)){
		
		document.getElementById("usernameE").innerHTML="<font color=red>用户名不能有空格</font>"
		
		return false;
	}
	document.getElementById("usernameE").innerHTML=""
	return true;
} 
function checkSpace(ssn){ 
	if(ssn.indexOf(" ")> -1) 
	return true; 
	return false;
} 
function checkPassword(){
	var pwd = reg.password.value;
	if(pwd.length<4 ||pwd.length>17){
//		alert("用户名长度在3-17位")
		document.getElementById("passwordE").innerHTML="<font color=red>密码长度在4-17位</font>"
		
		return false;
		
	}
	document.getElementById("passwordE").innerHTML=""
	return true;
}
function checkRePassword(){
	var pwd = reg.password.value;
	var repwd= reg.repassword.value;
	
	if(pwd!=repwd){
		document.getElementById("repasswordE").innerHTML="<font color=red>两次密码不一致</font>"
		
		return false;
	}
	document.getElementById("repasswordE").innerHTML=""
	return true;
}

function checkRealName(){
	var name = reg.name.value;
	if(name.length<1){
		document.getElementById("nameE").innerHTML="<font color=red>名字不能为空</font>"
		return false;
	}
	document.getElementById("nameE").innerHTML=""
	return true;
}
function checkMail(){
	var re = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	var mail = reg.email.value;
	if(!re.exec(mail)){
		document.getElementById("mailE").innerHTML="<font color=red>邮箱格式错误</font>"
			return false;
	}
	document.getElementById("mailE").innerHTML=""
	return true;
}
function checkCode(){
	var code= reg.ccode.value;
	if(code.length<1){
		alert("请输入验证码");
		return false;
	}
	return true;
}
